package cn.ai.shoes.common.exception.util;

import cn.hutool.json.JSONUtil;
import lombok.Data;

@Data
public class ErrorCode {

    /**
     * 错误码
     */
    private Integer code;
    /**
     * 错误提示
     */
    private String msg;

    public ErrorCode(Integer code, String message) {
        this.code = code;
        this.msg = message;
    }

    public static ErrorCode fromResult(String messageJson) {
        return  JSONUtil.toBean(messageJson, ErrorCode.class);
    }

    public String getResult() {
        return JSONUtil.toJsonStr(this);
    }

}
